from apscheduler.schedulers.blocking import BlockingScheduler
import subprocess
import datetime


def run_pytest():
    now = datetime.datetime.now()
    print(f"[{now}] 正在执行 pytest...")
    subprocess.run(["pytest"], shell=True)


scheduler = BlockingScheduler()
scheduler.add_job(run_pytest, 'cron', hour=16, minute=53)  # 每天 9:00 执行
print("APScheduler 定时任务已启动，等待每天9点执行 pytest...")
scheduler.start()
